//
//  CHMineViewController.m
//  CarFile
//
//  Created by 陈浩 on 2017/3/20.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHMineViewController.h"
#import "CHQuestionViewController.h"
#import "CHLoginViewController.h"
#import "AppDelegate.h"
@interface CHMineViewController ()<UIAlertViewDelegate>
{
    float autoSizeScaleX;
    float autoSizeScaleY;
}
@property (weak, nonatomic) IBOutlet UILabel *usernameLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UIButton *exitBtn;
- (IBAction)returnToQuestion:(id)sender;
- (IBAction)exitCurrentUser:(id)sender;

@end

@implementation CHMineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"账户中心";
    
    self.view.backgroundColor = [UIColor whiteColor];

    self.exitBtn.backgroundColor =  [UIColor colorWithHexString:@"148ec7" alpha:1.0f];
    self.exitBtn.layer.cornerRadius = 5;
    self.exitBtn.layer.masksToBounds = YES;
    
    self.usernameLabel.text = [Globle getInstance].userInfoDic[@"userflag"];
    self.addressLabel.text = [Globle getInstance].userInfoDic[@"areacn"];
  
    if(UIScreenH > 568){ // 这里以(iPhone5S)为准
        
        autoSizeScaleX = UIScreenW / 320;
        autoSizeScaleY = UIScreenH / 568;
        
    }else{
        
        autoSizeScaleX = 1;
        autoSizeScaleY = 1;
    }

    
  
    
}

- (IBAction)returnToQuestion:(id)sender {
    
    CHQuestionViewController *questionVC = [[CHQuestionViewController alloc] init];
    [self.navigationController pushViewController:questionVC animated:YES];
    
}

- (IBAction)exitCurrentUser:(id)sender {
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    
    CHLoginViewController *loginVC = [[CHLoginViewController alloc] init];
    
    window.rootViewController = loginVC;
//    UIAlertView *alrtView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"确定要退出当前账号吗" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
//    [alrtView show];
    
}


-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 1) {
        
    
        UIWindow *window = [UIApplication sharedApplication].keyWindow;
        
        CHLoginViewController *loginVC = [[CHLoginViewController alloc] init];
        
        window.rootViewController = loginVC;
      

//        CHLoginViewController *loginVC = [[CHLoginViewController alloc] init];
//        
//        [UIApplication sharedApplication].keyWindow.rootViewController = loginVC;
        
        
    }
}

-(void)dealloc{
    
    
    NSLog(@"销毁了");
}




-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    //    导航栏变为透明
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:0];
    //    让黑线消失的方法
    self.navigationController.navigationBar.shadowImage=[UIImage new];
    
}

@end
